//
//  NSString+path.m
//  SWA
//
//  Created by fanglin liu on 12-3-15.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "NSString+Path.h"

@implementation NSString (Path)

- (BOOL) isDescendantOfPath:(NSString*)path
{
    path = [NSString pathWithComponents:[path pathComponents]];
    NSString* workPath = [NSString pathWithComponents:[self pathComponents]];
    
    if ( [workPath length] <= [path length] )
    {
        return NO;
    }
    
    while ( [workPath length] >= [path length] )
    {
        if ( [workPath isEqualToString:path] ) 
        {
            return YES;
        }
        else
        {
            workPath = [workPath stringByDeletingLastPathComponent];
        }
    }
    
    return NO;
}

@end
